<template>
  <c-form-dialog
    ref="form"
    :visible.sync="innerVisible"
    :form-items="formItems"
    :form-data="formData"
    :table-name="tableName"
    :table-id="tableId"
    @close="handleClose"
    @success="handleSuccess"
    :before-save="handleBeforeSave"
  ></c-form-dialog>
</template>

<script>
import { mapGetters } from 'vuex'
import { enumLoanUnStatus } from '@/bank/views/limit/index'
export default {
  components: {},
  props: {
    visible: Boolean,
    tableId: String,
    formData: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      innerVisible: false,
      tableName: 'datum_one_county_industry',
      formItems: [
        {
          tag: 'select',
          itemAttrs: {
            label: '解保类型',
            rules: [{ required: true, message: '请选择解保类型', trigger: 'change' }],
          },
          attrs: {
            key: 'load_beh_status',
            options: enumLoanUnStatus,
            placeholder: '请选择解保类型',
          },
        },
        {
          tag: 'date',
          itemAttrs: {
            label: '解保时间',
            rules: [{ required: true, message: '请选择解保时间', trigger: 'change' }],
          },
          attrs: { key: 'un_gua_date', value: '', placeholder: '请选择解保时间' },
        },
        {
          tag: 'upload',
          itemAttrs: {
            label: '解保附件',
          },
          attrs: {
            class: 'form-control-ml',
            key: 'un_gua_attachment',
            value: '',
            placeholder: '解保附件',
            accept: '',
            fileName: 0,
            listType: '',
            dir: `/bank/limit-history/unload/${this.tableId}`,
          },
        },
      ],
    }
  },
  computed: {
    ...mapGetters(['user', 'clientId']),
    isCounty() {
      return this.user.orgRegionLever > 2
    },
  },
  watch: {
    visible(val) {
      this.innerVisible = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleBeforeSave(model) {
      model.is_confirm_un_gua = 1
      return model
    },
    handleClose() {
      this.$emit('update:visible', false)
    },
    handleSuccess(res) {
      this.$emit('success', res)
    },
  },
}
</script>
<style lang="scss" scoped></style>
